package leetCode;

/**
 * TODO
 *
 * @author 司松坡
 * @createTime 2023年03月02日
 */
public class LeetCode36 {
    public boolean isValidSudoku(char[][] board) {
        int[][] checkArrange = new int[9][9];
        int[][] checkRows = new int[9][9];
        int[][][] checkRound = new int[3][3][9];
        for (int i = 0; i < 9; i++) {
            for (int j = 0; j < 9; j++) {
                char seat = board[i][j];
                if (seat != '.') {
                    int seatInt = seat - '1';
                    if (checkArrange[i][seatInt] != 0 || checkRows[j][seatInt] != 0 || checkRound[i / 3][j / 3][seatInt] != 0){
                        return false;
                    }
                    checkArrange[i][seatInt]++;
                    checkRows[j][seatInt]++;
                    checkRound[i / 3][j / 3][seatInt]++;
                }
            }
        }
        return true;


    }

}
